﻿using Bilibili.Model.Common;
using Bilibili.Model.Danmaku;

namespace Avalonia.BiliBili.Libs.Models
{
    public sealed class LiveRoomDanmu : LiveDanmu
    {
        public LiveRoomDanmu(LiveDanmu danmu)
        {
            Type = danmu.Type;
            Value = danmu.Value;
            switch (danmu.Type)
            {
                case LiveDanmuTypes.Danmu:
                    {
                        IsDanmu = true;
                        Danmu = (Value as DanmuMsg) ?? default;
                        break;
                    }
                case LiveDanmuTypes.Gift:
                    {
                        IsGift = true;
                        if (Value is GiftMsg g)
                        {
                            Message = $"{g.Uname}赠送了{g.Num}个{g.GiftName}";
                            Icon = string.Empty;
                        }
                        break;
                    }
                case LiveDanmuTypes.SystemMsg:
                    {
                        IsMessage = true;
                        if (Value is WelcomeMsg w)
                            Message = $"{w.Uname}进入直播间";
                        break;
                    }
                case LiveDanmuTypes.Welcome:
                    {
                        IsMessage = true;
                        Message = Value.ToString();
                        break;
                    }
            }
        }
        public bool IsDanmu { get; private set; }
        public bool IsGift { get; private set; }
        public bool IsMessage { get; private set; }
        public DanmuMsg Danmu { get; private set; }
        public string Message { get; private set; }
        public string Icon { get; private set; }
    }
}